package designpatterns.chainofresponsibility;

import org.junit.Test;

/**
 * @author LiDong
 * @version 1.0.0
 * @createTime 2/15/2022 8:28 AM
 */
public class AppTest {


    private AbstractLogger getChainOfLogs() {
        AbstractLogger errorLogger = new ErrorLogger(AbstractLogger.ERROR);
        AbstractLogger fileLogger = new FileLogger(AbstractLogger.DEBUG);
        AbstractLogger consoleLogger = new ErrorLogger(AbstractLogger.INFO);
        errorLogger.setNextLogger(fileLogger);
        fileLogger.setNextLogger(consoleLogger);
        return errorLogger;
    }


    @Test
    public void test() {
        AbstractLogger loggerChain = getChainOfLogs();
        loggerChain.logMessage(AbstractLogger.INFO, "This is an information.");
        loggerChain.logMessage(AbstractLogger.DEBUG, "This is a debug level information.");
        loggerChain.logMessage(AbstractLogger.ERROR, "This is an error information.");
    }

}
